package JAVAcollectionsanddatastructures.binaryTree;

public class MybinaryTreeTest {
    public static void main(String[] args) {
        MybinaryTree mybinaryTree = new MybinaryTree();
        TreeNode root = mybinaryTree.createTree();//创建一棵树并返回根节点

        System.out.println("前序遍历结果为：");
        mybinaryTree.preOrder(root);
        System.out.println();
        System.out.println("中序遍历结果为：");
        mybinaryTree.inOrder(root);
        System.out.println();
        System.out.println("后序遍历结果为：");
        mybinaryTree.postOrder(root);
        System.out.println();
        System.out.println("层序遍历结果为：");
        mybinaryTree.levelOrder(root);
        System.out.println();

        System.out.println("=========输出二叉树结点个数===============");
        System.out.println(mybinaryTree.getSize1(root));
        System.out.println(mybinaryTree.getSize2(root));

        System.out.println("=========输出二叉树叶子节点的个数==========");
        System.out.println(mybinaryTree.getLeafSize1(root));
        System.out.println(mybinaryTree.getLeafSize2(root));

        System.out.println("=========输出第K层节点个数===============");
        System.out.println(mybinaryTree.getKLevelSize(root, 2));

        System.out.println("=========获取二叉树的高度================");
        System.out.println(mybinaryTree.getHeight(root));

        System.out.println("=========是否为平衡二叉树================");
        System.out.println(mybinaryTree.isBalanced(root));

        System.out.println("=========判断值为Value是否存在===========");
        try {
            TreeNode ret = mybinaryTree.find(root, 'E');
            System.out.println(ret.value);
//            Boolean flag = mybinaryTree.find1(root, 'N');
//            System.out.println(flag);
        }catch (NullPointerException e){
            e.printStackTrace();
            System.out.println("没有这个节点");
        }
        finally {

        }

        System.out.println("==========是否为一个完全二叉树============");
        System.out.println(mybinaryTree.isCompleteTree(root));

        System.out.println("===========非递归前序遍历================");
        System.out.println(mybinaryTree.preorderTraversal(root));

        System.out.println("===========非递归中序遍历================");
        System.out.println(mybinaryTree.inorderTraversal(root));

        System.out.println("===========非递归后序遍历================");
        System.out.println(mybinaryTree.postorderTraversal(root));

    }
}
